-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add required tests for go/mysql/hex
#14976
Conversation
Signed-off-by: Noble Mittal <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14976 +/- ##
==========================================
+ Coverage 47.26% 47.31% +0.05%
==========================================
Files 1138 1140 +2
Lines 238842 238962 +120
==========================================
+ Hits 112880 113069 +189
+ Misses 117368 117298 -70
- Partials 8594 8595 +1 ☔ View full report in Codecov by Sentry. |
go/mysql/hex/hex_test.go
Outdated
|
||
for _, tCase := range testCases { | ||
got := EncodeBytes(tCase.input) | ||
assert.Equalf(t, tCase.want, got, "got %v, want %v", got, tCase.want) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just do assert.Equal(t, tCase.want, got)
here and in the other cases. The additional stuff here doesn't seem to add much.
This also applies to the other cases here in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. Makes sense; I'll proceed accordingly.
Signed-off-by: Noble Mittal <[email protected]>
go/mysql/hex/hex_test.go
Outdated
// DecodeBytes should return an error for "é" as | ||
// hex.decode returns an error for non-ASCII characters | ||
err = DecodeBytes([]byte("testDst"), []byte("é")) | ||
assert.Errorf(t, err, "expected error to appear for invalid byte, got %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can also drop the Errorf
here. It's not very useful, as err
will always be nil
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...right. Done. Replaced the error message with DecodeBytes() should have errored as src contains non-ASCII character
.
Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Noble Mittal <[email protected]>
go/mysql/hex/hex_test.go
Outdated
@@ -98,5 +98,5 @@ func TestDecodeBytes(t *testing.T) { | |||
// DecodeBytes should return an error for "é" as | |||
// hex.decode returns an error for non-ASCII characters | |||
err = DecodeBytes([]byte("testDst"), []byte("é")) | |||
assert.Error(t, err) | |||
assert.Error(t, err, "DecodeBytes() should have errored as src contains non-ASCII character") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for having a custom message at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have added custom messages earlier in other tests too. So, I added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think it add a lot of value here? I think we can go for the minimal setup and only add something custom if there’s explicit value in doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: Noble Mittal <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Description
This PR adds required tests for
go/mysql/hex
Related Issue(s)
Fixes part of #14931
Checklist
Deployment Notes